package top.zhangjianyong.blog.manage.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zhangjianyong.blog.annotation.Permission;
import top.zhangjianyong.blog.enums.RoleKeys;
import top.zhangjianyong.blog.params.timeline.TimeLinePageParam;
import top.zhangjianyong.blog.params.timeline.TimeLinePushParam;
import top.zhangjianyong.blog.params.timeline.TimeLineRemoveParam;
import top.zhangjianyong.blog.params.timeline.TimeLineSaveOrUpdateParam;
import top.zhangjianyong.blog.response.ApiResponse;
import top.zhangjianyong.blog.service.TimeLineService;

/**
 * @author zhangjianyong
 * @since 2025/5/20 11:14
 */
@RequestMapping("/timeline")
@RestController
@Permission(roles = {RoleKeys.ADMIN})
public class TimeLineController {
  private final TimeLineService timeLineService;

  public TimeLineController(TimeLineService timeLineService) {
    this.timeLineService = timeLineService;
  }

  @PostMapping("/saveOrUpdate")
  public ApiResponse saveOrUpdate(@RequestBody @Validated TimeLineSaveOrUpdateParam param) {
    return timeLineService.saveOrUpdate(param);
  }

  @PostMapping("/remove")
  public ApiResponse remove(@RequestBody @Validated TimeLineRemoveParam param) {
    return timeLineService.remove(param);
  }

  @PostMapping("/page")
  public ApiResponse page(@RequestBody @Validated TimeLinePageParam param) {
    return timeLineService.page(param);
  }

  @PostMapping("/push")
  public ApiResponse push(@RequestBody @Validated TimeLinePushParam param) {
    return timeLineService.push(param);
  }
}
